﻿using Microsoft.Win32;

namespace TextNovelReader.Services;

public static class SystemService
{
    /// <summary>
    /// 判断操作系统是否打开了暗黑模式配色。
    /// </summary>
    /// <returns></returns>
    public static bool IsSystemDarkMode()
    {
        var key = Registry.CurrentUser.OpenSubKey(
            @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize");
        if (key == null)
            return false;

        object? registryValueObject = key.GetValue("AppsUseLightTheme");
        if (registryValueObject == null)
            return false;

        return (int)registryValueObject == 0;

    }
}
